import java.util.*;
public class Main
{
    public static int MOD = 109;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        int ret = n;
        for(int i = 0; i < m - 1; i++) {
            ret = ret * (n - 1) % MOD;
        }
        System.out.println(ret);
    }
}
